import React from "react"
import s from "@/assets/images/4.jpg"


// 创建组件
class Home extends React.Component{
  //计时器
  constructor(props) {
    super(props);
    this.state = { seconds: 0 };
  }

  tick() {
    this.setState(state => ({
      seconds: state.seconds + 1
    }));
  }

  componentDidMount() {
    this.interval = setInterval(() => this.tick(), 1000);
  }

  componentWillUnmount() {
    clearInterval(this.interval);
  }
  render() { // 每一个组件必须有 render
    const p = <p>周四了</p>

    const flag = true
    const list = ['a', 'b', 'c']
    const listDom = list.map((item,index) => <li key={index}>{item}</li>)
    console.log(listDom)

    return (
      <div className="home">
        <h3>home</h3>
        {/*  */}
        {p}
        <img src={s}></img>

        {flag ? <p>'true'</p> : <p>'false'</p>}
        {list}
        <ul>
          {listDom}
        </ul>
        Seconds: {this.state.seconds}
      </div>
      
    )
  }
}


export default Home
